package com.yunchen.BooksManagementSystem.login.dao;

import com.yunchen.BooksManagementSystem.utils.DBUtil;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.sql.Statement;

/**
 * @创建人
 * @创建时间
 * @描述
 */
public class LoginDaoImpl implements LoginDao {
    public void addUser(Statement stmt,String id,String password,String name,String grade,String direction) throws SQLException {
        Connection conn = DBUtil.getConnection();
        String insert = "INSERT INTO userinfo (userId,password,name,grade,direction) VALUES (?,?,?,?,?)";
        PreparedStatement ps = conn.prepareStatement(insert);
        ps.setString(1, id);
        ps.setString(2,password);
        ps.setString(3,name);
        ps.setString(4,grade);
        ps.setString(5,direction);
        int count = ps.executeUpdate();
        System.out.println(count);
        ps.close();
    }
}
